import React from "react";
import { connect } from "react-redux";
import { addListFun } from './service';

export const Cart = (props: any) => {
	const { list, addList } = props;
	return (
		<div>
			{list.map((item: any, index: number) => {
				return <div key={index}>{item}</div>;
			})}
			<button onClick={addList}>+</button>
		</div>
	);
};

const mapStateToProps = (state: any) => ({ list: state.list });

const mapDispatchToProps = (dispatch: any) => {
	return {
		addList() {
			// dispatch({ type: "ADD_LIST", data: "kkk" });
			dispatch(addListFun); // 方便业务逻辑抽离
		},
	};
};

export default connect(mapStateToProps, mapDispatchToProps)(Cart);
// rfcr
